package com.liu.producer.resolver.impl;


import com.liu.agreement.Agreement;
import com.liu.message.MessageTypeEnum;
import com.liu.message.impl.ResponseMessage;
import com.liu.resolver.Resolver;
import com.liu.serialization.Serialization;
import com.liu.serialization.SerializationProvider;

// 响应消息处理器
public class ResponseMessageResolver implements Resolver {

    @Override
    public boolean support(MessageTypeEnum messageTypeEnum) {
        return messageTypeEnum == MessageTypeEnum.RESPONSE;
    }

    @Override
    public Object resolve(Agreement agreement) {
        Serialization serialization = SerializationProvider.getSerialization(agreement.getSerializationType());
        return serialization.deserialization(ResponseMessage.class, (byte[]) agreement.getBody());
    }
}